﻿using LuShanTea.Service.Entities;
using System;
using System.Collections.Generic;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LuShanTea.Service.ModelConfig
{
    public class AddressConfig : EntityTypeConfiguration<Address>
    {
        public AddressConfig()
        {
            this.ToTable("T_Addresses");

            HasRequired(a => a.User).WithMany().HasForeignKey(a => a.UserId).WillCascadeOnDelete(false);
            HasRequired(a => a.Area).WithMany().HasForeignKey(a => a.AreaId).WillCascadeOnDelete(false);

            Property(a => a.ReciverName).IsRequired().HasMaxLength(16);
            Property(a => a.ReciverAddress).IsRequired().HasMaxLength(128);
            Property(a => a.PostEmail).IsRequired().HasMaxLength(6).IsUnicode(false);
            Property(a => a.PhoneNum).IsRequired().HasMaxLength(16).IsUnicode(false);
        }
    }
}
